﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ExpressionEditor="clr-namespace:NuSoft.ExpressionEditor;assembly=NuSoft.ExpressionEditor" x:Class="Demo.MainWindow"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="MainWindow" Height="350" Width="525"
    xmlns:this="clr-namespace:Demo"
    xmlns:exParser="clr-namespace:NuSoft.ExpressionEditor.ExampleParser;assembly=NuSoft.ExpressionEditor.ExampleParser">
    <Grid>
        <TabControl>
            <TabItem Header="Full">

                <ExpressionEditor:ExpressionEditor Margin="10" SourceObjType="{x:Type this:TestType}">
                    <ExpressionEditor:ExpressionEditor.Parser>
                        <exParser:MathParser/>
                    </ExpressionEditor:ExpressionEditor.Parser>
                </ExpressionEditor:ExpressionEditor>
            </TabItem>
            <TabItem Header="Without Property Grid">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                <ExpressionEditor:ExpressionEditor Name="eenopropgrid" Margin="10" SourceObjType="{x:Type this:TestType}">
                    <ExpressionEditor:ExpressionEditor.Style>
                        <Style TargetType="ExpressionEditor:ExpressionEditor">
                        <Setter Property="Template">
                            <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ExpressionEditor:ExpressionEditor}">
                                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition/>
                                            </Grid.RowDefinitions>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition/>
                                                <ColumnDefinition/>
                                            </Grid.ColumnDefinitions>
                                            <Grid Grid.ColumnSpan="2" Grid.Column="0">
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="80"/>
                                                            <ColumnDefinition Width="*"/>
                                                    <ColumnDefinition Width="Auto"/>
                                                </Grid.ColumnDefinitions>

                                                        <TextBox x:Name="Result_PART" IsEnabled="False" Text="{Binding ParseResult, RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"/>
                                                        <TextBox x:Name="ExpressionText_PART" Grid.Column="1" Text="{Binding ExpressionText, RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"/>
                                                <Button x:Name="EvaluateButton_PART" Grid.Column="2" Content="Evaluate"/>
                                            </Grid>
                                            <ListView x:Name="PropertiesList_PART" Grid.Row="1"  Grid.Column="0" ItemsSource="{TemplateBinding SourceProperties}">

                                            </ListView>
                                            <ListView x:Name="MethodsList_PART" Grid.Row="1" Grid.Column="1" ItemsSource="{TemplateBinding SupportedMethods}">
                                                <ListView.ItemContainerStyle>
                                                    <Style TargetType="ListViewItem">
                                                        <Setter Property="ToolTip" Value="{Binding Hint}"/>
                                                    </Style>
                                                </ListView.ItemContainerStyle>
                                                <ListView.ItemTemplate>
                                                    <DataTemplate>
                                                        <TextBlock Text="{Binding Display}"/>
                                                    </DataTemplate>
                                                </ListView.ItemTemplate>
                                            </ListView>
                                        </Grid>
                                    </Border>

                                </ControlTemplate>
                            </Setter.Value>
                            </Setter>
                        </Style>
                    </ExpressionEditor:ExpressionEditor.Style>
                    <ExpressionEditor:ExpressionEditor.Parser>
                        <exParser:MathParser/>
                    </ExpressionEditor:ExpressionEditor.Parser>
                    </ExpressionEditor:ExpressionEditor>
                    <TextBlock Grid.Row="1" Text="{Binding ExpressionText,ElementName=eenopropgrid}"/>
                </Grid>
            </TabItem>
            <TabItem Header="With Extended Toolkit PropertyGrid">
                <TabItem.Content>
                    <ExpressionEditor:ExpressionEditor Margin="10" SourceObjType="{x:Type this:TestType}" Name="extExample">
                        <ExpressionEditor:ExpressionEditor.Style>
                            <Style TargetType="ExpressionEditor:ExpressionEditor">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type ExpressionEditor:ExpressionEditor}">
                                            <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                                                <Grid>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="Auto"/>
                                                        <RowDefinition/>
                                                    </Grid.RowDefinitions>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition/>
                                                        <ColumnDefinition/>
                                                        <ColumnDefinition/>
                                                    </Grid.ColumnDefinitions>
                                                    <Grid Grid.ColumnSpan="2" Grid.Column="0">
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="80"/>
                                                            <ColumnDefinition Width="*"/>
                                                            <ColumnDefinition Width="Auto"/>
                                                        </Grid.ColumnDefinitions>

                                                        <TextBox x:Name="Result_PART" IsEnabled="False" Text="{Binding ParseResult, RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"/>
                                                        <TextBox x:Name="ExpressionText_PART" Grid.Column="1" Text="{Binding ExpressionText, RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}"/>
                                                        <Button x:Name="EvaluateButton_PART" Grid.Column="2" Content="Evaluate"/>
                                                    </Grid>
                                                    <ListView x:Name="PropertiesList_PART" Grid.Row="1"  Grid.Column="0" ItemsSource="{TemplateBinding SourceProperties}">

                                                    </ListView>
                                                    <ListView x:Name="MethodsList_PART" Grid.Row="1" Grid.Column="1" ItemsSource="{TemplateBinding SupportedMethods}">
                                                        <ListView.ItemContainerStyle>
                                                            <Style TargetType="ListViewItem">
                                                                <Setter Property="ToolTip" Value="{Binding Hint}"/>
                                                            </Style>
                                                        </ListView.ItemContainerStyle>
                                                        <ListView.ItemTemplate>
                                                            <DataTemplate>
                                                                <TextBlock Text="{Binding Display}"/>
                                                            </DataTemplate>
                                                        </ListView.ItemTemplate>
                                                    </ListView>
                                                    <xctk:PropertyGrid Grid.Column="2" Grid.RowSpan="2" AutoGenerateProperties="True" SelectedObject="{Binding SourceObj,ElementName=extExample}">
                                                        
                                                    </xctk:PropertyGrid>
                                                </Grid>
                                            </Border>

                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ExpressionEditor:ExpressionEditor.Style>
                        <ExpressionEditor:ExpressionEditor.Parser>
                            <exParser:MathParser/>
                        </ExpressionEditor:ExpressionEditor.Parser>
                    </ExpressionEditor:ExpressionEditor>
                </TabItem.Content>
            </TabItem>
            <TabItem Header="no source type">

                <ExpressionEditor:ExpressionEditor Margin="10">
                    <ExpressionEditor:ExpressionEditor.Parser>
                        <exParser:MathParser/>
                    </ExpressionEditor:ExpressionEditor.Parser>
                </ExpressionEditor:ExpressionEditor>
            </TabItem>
            <TabItem Header="nothing">

                <ExpressionEditor:ExpressionEditor Margin="10">
                </ExpressionEditor:ExpressionEditor>
            </TabItem>
        </TabControl>

    </Grid>
</Window>
